/**
 *  iBizSys 5.0 机器人生产代码（不要直接修改当前代码）
 *  http://www.ibizsys.net
 */
package com.sa.ibiz.demo.srv.demo.service;


import java.util.ArrayList;
import java.util.List;
import java.util.HashMap;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Component;
import net.ibizsys.paas.exception.ErrorException;
import net.ibizsys.paas.core.PluginActionResult;
import net.ibizsys.paas.core.IDataEntity;
import net.ibizsys.paas.core.IDEDataSetFetchContext;
import net.ibizsys.paas.db.DBCallResult;
import net.ibizsys.paas.db.DBFetchResult;
import net.ibizsys.paas.db.IProcParam;
import net.ibizsys.paas.util.StringHelper;
import net.ibizsys.paas.util.StringBuilderEx;
import net.ibizsys.paas.core.Errors;
import net.ibizsys.paas.core.ActionContext;
import net.ibizsys.paas.data.DataObject;
import net.ibizsys.paas.service.ServiceGlobal;
import net.ibizsys.paas.entity.IEntity;
import net.ibizsys.paas.demodel.IDataEntityModel;
import net.ibizsys.paas.demodel.DEModelGlobal;
import net.ibizsys.paas.demodel.IDELogicModel;
import net.ibizsys.paas.dao.DAOGlobal;
import net.ibizsys.paas.web.WebContext;
import net.ibizsys.paas.service.IService;
import net.ibizsys.paas.util.DataTypeHelper;
import net.ibizsys.paas.util.KeyValueHelper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.ibizsys.paas.db.SelectCond;
import net.ibizsys.paas.service.IServiceWork;
import net.ibizsys.paas.service.IServicePlugin;
import net.ibizsys.paas.service.ITransaction;
import net.ibizsys.paas.dao.IDAO;
import net.ibizsys.paas.service.CloneSession;
import net.ibizsys.paas.service.ServiceBase;
import net.ibizsys.paas.entity.EntityFieldError;
import net.ibizsys.paas.entity.EntityError;
import java.sql.Timestamp;
import net.ibizsys.paas.util.DefaultValueHelper;
import javax.annotation.PostConstruct;
import net.ibizsys.paas.service.IDataContextParam;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


import com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService;
import com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL;

import com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDER;
import com.sa.ibiz.demo.srv.demo.dao.IBZ5ORDERDAO;
import com.sa.ibiz.demo.srv.demo.demodel.IBZ5ORDERDEModel;


/**
 * 实体[IBZ5ORDER] 服务对象基类
 */
@Component
public class IBZ5ORDERService extends com.sa.ibiz.demo.srv.MyTestSysSysServiceBase<IBZ5ORDER> {
    private static final Log log = LogFactory.getLog(IBZ5ORDERService.class);
    /**
     * 实体数据集合[审核通过和未通过]标识
     */
    public final static String DATASET_STATE30AND40 = "State30And40";
    /**
     * 实体数据集合[DEFAULT]标识
     */
    public final static String DATASET_DEFAULT = "DEFAULT";
    /**
     * 实体数据集合[订单状态为未提交的]标识
     */
    public final static String DATASET_STATE10 = "State10";


    public IBZ5ORDERService () {
        super();

    }

    /**
     * 获取实体[IBZ5ORDER]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */
    public static IBZ5ORDERService getInstance() throws Exception {
        return getInstance(null);
    }

    /**
     * 获取实体[IBZ5ORDER]服务对象
     * @param sessionFactory
     * @return
     * @throws Exception
     */
    public static IBZ5ORDERService getInstance(SessionFactory sessionFactory) throws Exception {
        return (IBZ5ORDERService)ServiceGlobal.getService(IBZ5ORDERService.class, sessionFactory);
    }

    /**
     * Spring注册后执行构造处理
     * @throws Exception
     */
    @PostConstruct
    public void postConstruct() throws Exception {
        ServiceGlobal.registerService(getServiceId(), this);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getServiceId()
     */
    @Override
    protected String getServiceId() {
        return "com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERService";
    }

    private IBZ5ORDERDEModel iBZ5ORDERDEModel;
    /**
     * 获取实体[IBZ5ORDER]模型对象
     */
    public  IBZ5ORDERDEModel getIBZ5ORDERDEModel() {
        if(this.iBZ5ORDERDEModel==null) {
            try {
                this.iBZ5ORDERDEModel = (IBZ5ORDERDEModel)DEModelGlobal.getDEModel("com.sa.ibiz.demo.srv.demo.demodel.IBZ5ORDERDEModel");
            } catch(Exception ex) {
            }
        }
        return this.iBZ5ORDERDEModel;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getDEModel()
     */
    @Override
    public  IDataEntityModel getDEModel() {
        return this.getIBZ5ORDERDEModel();
    }


    private IBZ5ORDERDAO iBZ5ORDERDAO;

    /**
     * 获取实体[IBZ5ORDER]数据操作对象
     */
    public  IBZ5ORDERDAO getIBZ5ORDERDAO() {
        if(this.iBZ5ORDERDAO==null) {
            try {
                this.iBZ5ORDERDAO= (IBZ5ORDERDAO)DAOGlobal.getDAO("com.sa.ibiz.demo.srv.demo.dao.IBZ5ORDERDAO",this.getSessionFactory());
            } catch(Exception ex) {
            }
        }
        return this.iBZ5ORDERDAO;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.IService#getDAO()
     */
    @Override
    public  IDAO getDAO() {
        return this.getIBZ5ORDERDAO();
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onfetchDataSet(java.lang.String, net.ibizsys.paas.core.IDEDataSetFetchContext)
     */
    @Override
    protected DBFetchResult onfetchDataSet(String strDataSetName,IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {
        if(StringHelper.compare(strDataSetName,DATASET_STATE30AND40,true)==0) {
            return this.fetchState30And40(iDEDataSetFetchContext);
        }
        if(StringHelper.compare(strDataSetName,DATASET_DEFAULT,true)==0) {
            return this.fetchDefault(iDEDataSetFetchContext);
        }
        if(StringHelper.compare(strDataSetName,DATASET_STATE10,true)==0) {
            return this.fetchState10(iDEDataSetFetchContext);
        }
        return super.onfetchDataSet(strDataSetName,iDEDataSetFetchContext);
    }

    /**
     * 获取数据集合
     * @param strDataSetName
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    @Override
    protected DBFetchResult onfetchDataSetTemp(String strDataSetName,IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {
        if(StringHelper.compare(strDataSetName,DATASET_STATE30AND40,true)==0) {
            return this.fetchTempState30And40(iDEDataSetFetchContext);
        }
        if(StringHelper.compare(strDataSetName,DATASET_DEFAULT,true)==0) {
            return this.fetchTempDefault(iDEDataSetFetchContext);
        }
        if(StringHelper.compare(strDataSetName,DATASET_STATE10,true)==0) {
            return this.fetchTempState10(iDEDataSetFetchContext);
        }
        return super.onfetchDataSetTemp(strDataSetName,iDEDataSetFetchContext);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onExecuteAction(java.lang.String, net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected  void onExecuteAction(String strAction,IEntity entity) throws Exception {
        super.onExecuteAction(strAction,entity);
    }

    /**
     * 获取数据集合[审核通过和未通过]
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchState30And40(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_STATE30AND40,false);
        // dbFetchResult.getDataSet().cacheDataRow();
        // session.close();
        return dbFetchResult;
    }

    /**
    * 获取数据集合[审核通过和未通过]（临时数据模型）
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchTempState30And40(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_STATE30AND40,true);
        return dbFetchResult;
    }


    /**
     * 获取数据集合[DEFAULT]
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchDefault(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_DEFAULT,false);
        // dbFetchResult.getDataSet().cacheDataRow();
        // session.close();
        return dbFetchResult;
    }

    /**
    * 获取数据集合[DEFAULT]（临时数据模型）
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchTempDefault(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_DEFAULT,true);
        return dbFetchResult;
    }


    /**
     * 获取数据集合[订单状态为未提交的]
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchState10(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_STATE10,false);
        // dbFetchResult.getDataSet().cacheDataRow();
        // session.close();
        return dbFetchResult;
    }

    /**
    * 获取数据集合[订单状态为未提交的]（临时数据模型）
     * @param iDEDataSetFetchContext
     * @return
     * @throws Exception
     */
    public DBFetchResult fetchTempState10(IDEDataSetFetchContext iDEDataSetFetchContext) throws Exception {

        DBFetchResult dbFetchResult =  doServiceFetchWork(iDEDataSetFetchContext,DATASET_STATE10,true);
        return dbFetchResult;
    }






    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onFillParentInfo(net.ibizsys.paas.entity.IEntity, java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
    protected void onFillParentInfo(IBZ5ORDER et,String strParentType,String strTypeParam,String strParentKey) throws Exception {
        //关系类型 : DER1N ,主实体 :IBZ5CUSTOMER / 客户
        if (((StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER1N, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_DER11, true) == 0)
                ||(StringHelper.compare(strParentType, WebContext.PARAM_PARENTTYPE_SYSDER11, true) == 0))
                && (StringHelper.compare(strTypeParam, "DER1N_IBZ5ORDER_IBZ5CUSTOMER_IBZ5CUSTOMERID", true)==0)) {
            IService iService= ServiceGlobal.getService("com.sa.ibiz.demo.srv.demo.service.IBZ5CUSTOMERService",this.getSessionFactory());
            com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity = ( com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER)iService.getDEModel().createEntity();
            parentEntity.set(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER.FIELD_IBZ5CUSTOMERID,DataTypeHelper.parse(25,strParentKey));
            if(strParentKey.indexOf(ServiceBase.TEMPKEY) == 0)
                iService.getTemp(parentEntity);
            else
                iService.get(parentEntity);
            this.onFillParentInfo_IBZ5CUSTOMER(et,parentEntity );
            return;
        }
        super.onFillParentInfo(et,strParentType,strTypeParam,strParentKey);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncDER1NData(java.lang.String, java.lang.String, java.lang.String)
     */
    @Override
    protected String onSyncDER1NData(String strDER1NId, String strParentKey, String strDatas) throws Exception {
        return super.onSyncDER1NData( strDER1NId,  strParentKey,  strDatas);
    }


    /**
    * 填充数据的父数据信息[客户]
    * @param et 当前数据对象
    * @param parentEntity 父数据对象
    * @throws Exception
    */
    protected void onFillParentInfo_IBZ5CUSTOMER(IBZ5ORDER et,com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
        et.setIBZ5CUSTOMERId(parentEntity.getIBZ5CUSTOMERId());
        et.setIBZ5CUSTOMERName(parentEntity.getIBZ5CUSTOMERName());
    }




    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onFillEntityFullInfo(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onFillEntityFullInfo(IBZ5ORDER et, boolean bCreate) throws Exception {
        //填充新建默认值
        if(bCreate) {
        }
        super.onFillEntityFullInfo(et, bCreate);

        //填充物理化外键相关属性
        //关系类型 : DER1N ,主实体 :IBZ5CUSTOMER / 客户
        onFillEntityFullInfo_IBZ5CUSTOMER(et, bCreate);
    }

    /**
    * 填充实体的数据信息 客户
    * @param et
    * @param bCreate 是否建立
    * @throws Exception
    */
    protected void onFillEntityFullInfo_IBZ5CUSTOMER(IBZ5ORDER et, boolean bCreate) throws Exception {
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onWriteBackParent(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onWriteBackParent(IBZ5ORDER et, boolean bCreate) throws Exception {
        super.onWriteBackParent(et, bCreate);
    }




    /**
     * 通过关系[客户]父数据查询数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public java.util.ArrayList<IBZ5ORDER> selectByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
        return selectByIBZ5CUSTOMER(parentEntity,"");
    }
    /**
     * 通过关系[客户]父数据查询数据
     * @param parentEntity 父数据
     * @param strOrderInfo 排序信息
     * @throws Exception
     */
    public java.util.ArrayList<IBZ5ORDER> selectByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity,String strOrderInfo) throws Exception {
        SelectCond selectCond = new SelectCond();
        selectCond.setConditon(IBZ5ORDER.FIELD_IBZ5CUSTOMERID, parentEntity.getIBZ5CUSTOMERId());
        selectCond.setOrderInfo(strOrderInfo);
        onFillSelectByIBZ5CUSTOMERCond(selectCond);
        return this.select(selectCond);
    }

    /**
     * 填充关系[客户]父数据查询附加条件
     * @param selectCond 查询条件对象
     * @throws Exception
     */
    protected void onFillSelectByIBZ5CUSTOMERCond(SelectCond selectCond) throws Exception {

    }




    /**
     * 判断是否能够通过关系[客户]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void testRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
    }


    /**
     * 通过关系[客户]重置数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void resetIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
        java.util.ArrayList<IBZ5ORDER> list =  this.selectByIBZ5CUSTOMER(parentEntity);
        for(IBZ5ORDER item:list) {
            IBZ5ORDER item2 = (IBZ5ORDER)getDEModel().createEntity();
            item2.setIBZ5ORDERId(item.getIBZ5ORDERId());
            item2.setIBZ5CUSTOMERId(null);
            this.update(item2);
        }
    }


    /**
     * 通过关系[客户]删除数据
     * @param parentEntity 父数据
     * @throws Exception
     */
    public void removeByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
        final com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity2 = parentEntity;
        this.doServiceWork(new IServiceWork() {
            @Override
            public void execute(ITransaction iTransaction) throws Exception {
                onBeforeRemoveByIBZ5CUSTOMER(parentEntity2);
                internalRemoveByIBZ5CUSTOMER(parentEntity2);
                onAfterRemoveByIBZ5CUSTOMER(parentEntity2);
            }
        });
    }

    /**
     * 通过关系[客户]删除数据之前调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onBeforeRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {

    }

    /**
    * 内部删除数据，通过关系[客户]
    * @param parentEntity 父数据
    * @throws Exception
    */
    protected void internalRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {
        java.util.ArrayList<IBZ5ORDER> removeList = selectByIBZ5CUSTOMER(parentEntity);
        onBeforeRemoveByIBZ5CUSTOMER(parentEntity,removeList );

        // 执行删除
        for (IBZ5ORDER item : removeList ) {
            remove(item );
        }
        onAfterRemoveByIBZ5CUSTOMER(parentEntity,removeList );
    }

    /**
     * 通过关系[客户]删除数据之后调用
     * @param parentEntity 父数据
     * @throws Exception
     */
    protected void onAfterRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity) throws Exception {

    }

    /**
     * 通过关系[客户]删除数据之前调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onBeforeRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity,java.util.ArrayList<IBZ5ORDER> removeList) throws Exception {

    }

    /**
     * 通过关系[客户]删除数据之后调用
     * @param parentEntity 父数据
     * @param removeList 要删除的数据清单
     * @throws Exception
     */
    protected void onAfterRemoveByIBZ5CUSTOMER(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER parentEntity,java.util.ArrayList<IBZ5ORDER> removeList) throws Exception {

    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onBeforeRemove(net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected void onBeforeRemove(IBZ5ORDER et) throws Exception {
        //删除 关系 订单明细 数据
        if(true) {
            IBZ5ORDERDETAILService service = (IBZ5ORDERDETAILService)ServiceGlobal.getService(IBZ5ORDERDETAILService.class,this.getSessionFactory());
            service.testRemoveByIBZ5ORDER(et);
            service.removeByIBZ5ORDER(et);
        }
        super.onBeforeRemove(et);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onBeforeRemoveTemp(net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected void onBeforeRemoveTemp(IBZ5ORDER et) throws Exception {
        //删除 关系 订单明细 数据
        if(true) {
            IBZ5ORDERDETAILService service = (IBZ5ORDERDETAILService)ServiceGlobal.getService(IBZ5ORDERDETAILService.class,this.getSessionFactory());
            service.removeTempByIBZ5ORDER(et);
        }
        super.onBeforeRemoveTemp(et);
    }


    @Override
    protected void getRelatedDataTempMajor(IBZ5ORDER et) throws Exception {
        getRelatedDataTempMajor_IBZ5ORDERDETAIL(et);
        super.getRelatedDataTempMajor(et);
    }

    protected void getRelatedDataTempMajor_IBZ5ORDERDETAIL(IBZ5ORDER et) throws Exception {
        com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService service = ( com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService)ServiceGlobal.getService(com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService.class,this.getSessionFactory());
        java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> list = null;
        String strKeyValue = et.getIBZ5ORDERId();
        if(strKeyValue.indexOf(TEMPKEY)!=0)
            list = service.selectByIBZ5ORDER(et);
        else
            list = service.selectTempByIBZ5ORDER(et);
        for(com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL entity:list) {
            service.getTempMajor(entity);
        }
    }


    @Override
    protected void updateRelatedDataTempMajor(IBZ5ORDER tempET,IBZ5ORDER oriET) throws Exception {
        java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> iBZ5ORDERDETAILlist = updateRelatedDataTempMajor_removeIBZ5ORDERDETAIL(tempET,oriET);

        updateRelatedDataTempMajor_updateIBZ5ORDERDETAIL(tempET,oriET,iBZ5ORDERDETAILlist);
        super.updateRelatedDataTempMajor(tempET, oriET);
    }


    protected java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> updateRelatedDataTempMajor_removeIBZ5ORDERDETAIL(IBZ5ORDER tempET,IBZ5ORDER oriET) throws Exception {
        com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService service = ( com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService)ServiceGlobal.getService(com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService.class,this.getSessionFactory());
        java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> tempList = service.selectTempByIBZ5ORDER(tempET);
        java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> oriList = service.selectByIBZ5ORDER(oriET);

        //放入Map中
        java.util.HashMap<Object,com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> oriMap = new java.util.HashMap<Object,com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL>();
        for(com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL entity:oriList) {
            oriMap.put(entity.getIBZ5ORDERDETAILId(),entity);
        }
        for(com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL entity:tempList) {
            Object oriKey = entity.get(ORIGINKEY);
            oriMap.remove(oriKey);
        }

        //移除删除的
        for(com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL entity: oriMap.values() ) {
            service.remove(entity);
        }

        return tempList;
    }

    protected void updateRelatedDataTempMajor_updateIBZ5ORDERDETAIL(IBZ5ORDER tempET,IBZ5ORDER oriET,java.util.ArrayList<com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL> updateList) throws Exception {
        if(updateList==null)
            return;
        com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService service = ( com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService)ServiceGlobal.getService(com.sa.ibiz.demo.srv.demo.service.IBZ5ORDERDETAILService.class,this.getSessionFactory());
        //建立
        for(com.sa.ibiz.demo.srv.demo.entity.IBZ5ORDERDETAIL entity:updateList) {
            service.updateTempMajor(entity);
        }
    }
    /**
     * 替换父数据信息
     * @param et
     * @throws Exception
     */
    @Override
    protected void replaceParentInfo(IBZ5ORDER et,CloneSession cloneSession) throws Exception {
        super.replaceParentInfo(et, cloneSession);
        //循环所有的从关系，判断有误替换
        if(et.getIBZ5CUSTOMERId()!=null) {
            IEntity entity = cloneSession.getEntity("IBZ5CUSTOMER",et.getIBZ5CUSTOMERId());
            if(entity !=null) {
                onFillParentInfo_IBZ5CUSTOMER(et,(com.sa.ibiz.demo.srv.demo.entity.IBZ5CUSTOMER) entity);
            }
        }
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onRemoveEntityUncopyValues(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onRemoveEntityUncopyValues(IBZ5ORDER et, boolean bTempMode) throws Exception {
        super.onRemoveEntityUncopyValues(et,  bTempMode);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onCheckEntity(boolean, net.ibizsys.paas.entity.IEntity, boolean, boolean, net.ibizsys.paas.entity.EntityError)
     */
    @Override
    protected void onCheckEntity(boolean bBaseMode,IBZ5ORDER  et, boolean bCreate, boolean bTempMode,EntityError entityError) throws Exception {
        EntityFieldError entityFieldError = null;
        //检查属性 总金额
        entityFieldError = onCheckField_AMOUNT( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 明细数
        entityFieldError = onCheckField_DETAILNUM( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 客户标识
        entityFieldError = onCheckField_IBZ5CUSTOMERId( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单标识
        entityFieldError = onCheckField_IBZ5ORDERId( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单名称
        entityFieldError = onCheckField_IBZ5ORDERName( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 备注
        entityFieldError = onCheckField_MEMO( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 审批意见
        entityFieldError = onCheckField_OPINION( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单状态
        entityFieldError = onCheckField_ORDERSTATE( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单时间
        entityFieldError = onCheckField_ORDERTIME( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单类型
        entityFieldError = onCheckField_ORDERTYPE( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        //检查属性 订单编号
        entityFieldError = onCheckField_ORDERUID( bBaseMode,  et,  bCreate,  bTempMode);
        if(entityFieldError!=null) {
            entityError.register(entityFieldError);
        }
        super.onCheckEntity(bBaseMode,et,  bCreate,bTempMode,entityError);
    }


    /**
     * 获取属性[AMOUNT]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_AMOUNT(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isAMOUNTDirty())
            return null;

        Double value = et.getAMOUNT();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_AMOUNT_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_AMOUNT);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[DETAILNUM]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_DETAILNUM(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isDETAILNUMDirty())
            return null;

        Integer value = et.getDETAILNUM();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_DETAILNUM_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_DETAILNUM);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[IBZ5CUSTOMERId]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_IBZ5CUSTOMERId(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isIBZ5CUSTOMERIdDirty())
            return null;

        String value = et.getIBZ5CUSTOMERId();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_IBZ5CUSTOMERId_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_IBZ5CUSTOMERID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[IBZ5ORDERId]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_IBZ5ORDERId(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isIBZ5ORDERIdDirty())
            return null;

        String value = et.getIBZ5ORDERId();
        if(bBaseMode) {
            if(bCreate) {
                if(StringHelper.isNullOrEmpty(value)) {
                    EntityFieldError entityFieldError = new EntityFieldError();
                    entityFieldError.setFieldName(IBZ5ORDER.FIELD_IBZ5ORDERID);
                    entityFieldError.setErrorType(EntityFieldError.ERROR_EMPTY);
                    return entityFieldError;
                }
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_IBZ5ORDERId_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_IBZ5ORDERID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[IBZ5ORDERName]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_IBZ5ORDERName(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isIBZ5ORDERNameDirty())
            return null;

        String value = et.getIBZ5ORDERName();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_IBZ5ORDERName_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_IBZ5ORDERNAME);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[MEMO]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_MEMO(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isMEMODirty())
            return null;

        String value = et.getMEMO();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_MEMO_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_MEMO);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[OPINION]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_OPINION(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isOPINIONDirty())
            return null;

        String value = et.getOPINION();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_OPINION_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_OPINION);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ORDERSTATE]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ORDERSTATE(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isORDERSTATEDirty())
            return null;

        String value = et.getORDERSTATE();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ORDERSTATE_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_ORDERSTATE);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ORDERTIME]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ORDERTIME(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isORDERTIMEDirty())
            return null;

        Timestamp value = et.getORDERTIME();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ORDERTIME_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_ORDERTIME);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ORDERTYPE]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ORDERTYPE(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isORDERTYPEDirty())
            return null;

        String value = et.getORDERTYPE();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ORDERTYPE_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_ORDERTYPE);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
        }
        return null;
    }


    /**
     * 获取属性[ORDERUID]值错误
     * @param bBaseMode 是否为基本检查模式，基本检查模式执行值类型，长度及属性值规则检查，非基本模式进行重复值检查
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据
     * @param bTempMode 是否为临时数据模式
     * @throws Exception
     */
    protected EntityFieldError onCheckField_ORDERUID(boolean bBaseMode,IBZ5ORDER et, boolean bCreate, boolean bTempMode) throws Exception {
        //判断是否有值
        if(!et.isORDERUIDDirty())
            return null;

        String value = et.getORDERUID();
        if(bBaseMode) {
            if(bCreate) {
            }

            String strRuleInfo  = null;
            //检查值规则[默认规则]
            strRuleInfo =onTestValueRule_ORDERUID_Default( et,  bCreate,  bTempMode);
            if(!StringHelper.isNullOrEmpty(strRuleInfo)) {
                EntityFieldError entityFieldError = new EntityFieldError();
                entityFieldError.setFieldName(IBZ5ORDER.FIELD_ORDERUID);
                entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                entityFieldError.setErrorInfo(strRuleInfo);
                return entityFieldError;
            }
        } else {
            boolean bCheckDup = true;
            //重复值判断
            if(bCheckDup) {
                String strRangeDEFieldName = "";
                String strDupCheckInfo = checkFieldDupRule(getIBZ5ORDERDEModel(),IBZ5ORDER.FIELD_ORDERUID,strRangeDEFieldName,  et,  bCreate,   bTempMode);
                if(!StringHelper.isNullOrEmpty(strDupCheckInfo)) {
                    EntityFieldError entityFieldError = new EntityFieldError();
                    entityFieldError.setFieldName(IBZ5ORDER.FIELD_ORDERUID);
                    entityFieldError.setErrorType(EntityFieldError.ERROR_VALUERULE);
                    entityFieldError.setErrorInfo(strDupCheckInfo);
                    return entityFieldError;
                }
            }
        }
        return null;
    }




    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncEntity(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onSyncEntity(IBZ5ORDER et, boolean bRemove) throws Exception {
        super.onSyncEntity( et,  bRemove);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onSyncIndexEntities(net.ibizsys.paas.entity.IEntity, boolean)
     */
    @Override
    protected void onSyncIndexEntities(IBZ5ORDER et,boolean bRemove) throws Exception {
        super.onSyncIndexEntities(et,bRemove);
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#getDataContextValue(net.ibizsys.paas.entity.IEntity, java.lang.String, net.ibizsys.paas.service.IDataContextParam)
     */
    @Override
    public Object getDataContextValue(IBZ5ORDER et,String strField,IDataContextParam iDataContextParam)throws Exception {
        Object objValue = null;
        if(iDataContextParam!=null) {
        }

        objValue = super.getDataContextValue(et,strField,iDataContextParam);
        if(objValue!=null)
            return objValue;

        return null;
    }



    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onTestValueRule(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity, boolean, boolean)
     */
    @Override
    protected String onTestValueRule(String strDEFieldName,String strRule,IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_OPINION,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_OPINION_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_IBZ5ORDERNAME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_IBZ5ORDERName_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_DETAILNUM,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_DETAILNUM_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_UPDATEMAN,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_UpdateMan_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_CREATEMAN,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_CreateMan_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_MEMO,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_MEMO_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_IBZ5ORDERID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_IBZ5ORDERId_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_ORDERTIME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ORDERTIME_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_ORDERSTATE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ORDERSTATE_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_UPDATEDATE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_UpdateDate_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_CREATEDATE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_CreateDate_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_ORDERUID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ORDERUID_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_AMOUNT,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_AMOUNT_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_ORDERTYPE,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_ORDERTYPE_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_IBZ5CUSTOMERNAME,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_IBZ5CUSTOMERName_Default(et,bCreate,bTempMode);
        if((StringHelper.compare(strDEFieldName,IBZ5ORDER.FIELD_IBZ5CUSTOMERID,true)==0)
                &&(StringHelper.compare(strRule,"DEFAULT",true)==0))
            return onTestValueRule_IBZ5CUSTOMERId_Default(et,bCreate,bTempMode);

        return super.onTestValueRule( strDEFieldName, strRule, et,bCreate, bTempMode);
    }

    /**
     * 判断值规则[审批意见][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_OPINION_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("OPINION", et, bTempMode,null,false,1048576,true,"内容长度必须小于等于[1048576]")))
                return null;
            return "内容长度必须小于等于[1048576]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[订单名称][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_IBZ5ORDERName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("IBZ5ORDERNAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
                return null;
            return "内容长度必须小于等于[200]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[明细数][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_DETAILNUM_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[更新人][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_UpdateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("UPDATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[建立人][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_CreateMan_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("CREATEMAN", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[备注][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_MEMO_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("MEMO", et, bTempMode,null,false,1048576,true,"内容长度必须小于等于[1048576]")))
                return null;
            return "内容长度必须小于等于[1048576]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[订单标识][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_IBZ5ORDERId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("IBZ5ORDERID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[订单时间][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ORDERTIME_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[订单状态][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ORDERSTATE_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("ORDERSTATE", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[更新时间][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_UpdateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[建立时间][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_CreateDate_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[订单编号][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ORDERUID_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("ORDERUID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[总金额][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_AMOUNT_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        return null;
    }

    /**
     * 判断值规则[订单类型][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_ORDERTYPE_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("ORDERTYPE", et, bTempMode,null,false,60,true,"内容长度必须小于等于[60]")))
                return null;
            return "内容长度必须小于等于[60]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[客户名称][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_IBZ5CUSTOMERName_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("IBZ5CUSTOMERNAME", et, bTempMode,null,false,200,true,"内容长度必须小于等于[200]")))
                return null;
            return "内容长度必须小于等于[200]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 判断值规则[客户标识][默认规则]
     * @param et 当前数据对象
     * @param bCreate 是否为新建数据模式
     * @param bTempMode 是否为临时数据模式
     * @return
     * @throws Exception
     */
    protected String onTestValueRule_IBZ5CUSTOMERId_Default(IEntity et,boolean bCreate,boolean bTempMode) throws Exception {
        try {
            if((checkFieldStringLengthRule("IBZ5CUSTOMERID", et, bTempMode,null,false,100,true,"内容长度必须小于等于[100]")))
                return null;
            return "内容长度必须小于等于[100]";
        } catch(Exception ex) {
            return ex.getMessage();
        }
    }

    /**
     * 是否为更新准备最后一次数据，优化操作
     * @return
     */
    @Override
    protected boolean isPrepareLastForUpdate() {
        return true;
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.service.ServiceBase#onMergeChild(java.lang.String, java.lang.String, net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected boolean onMergeChild(String strChildType, String strTypeParam, IBZ5ORDER et) throws Exception {
        boolean bRet = false;
        //TODO:子关系  DER1N_IBZ5ORDERDETAIL_IBZ5ORDER_IBZ5ORDERID 没有定义关系代码名称，无法输出执行代码
        log.error("子关系  DER1N_IBZ5ORDERDETAIL_IBZ5ORDER_IBZ5ORDERID 没有定义关系代码名称，无法输出执行代码");
        if(super.onMergeChild( strChildType, strTypeParam,  et))
            bRet = true;
        return bRet;
    }



    /**
     * 更新父数据
     * @param et
     * @throws Exception
     */
    @Override
    protected void onUpdateParent(IBZ5ORDER et)throws Exception {
        super.onUpdateParent(et);
    }


    /**
     * 拷贝源数据明细
     *
     * @param et
     * @param objSourceKey
     * @throws Exception
     */
    @Override
    protected void onCopyDetails(IBZ5ORDER et, Object objSourceKey) throws Exception {
        IBZ5ORDER srcET = new IBZ5ORDER();
        srcET.set(IBZ5ORDER.FIELD_IBZ5ORDERID,objSourceKey);
        String strKeyValue = DataObject.getStringValue(et.get(IBZ5ORDER.FIELD_IBZ5ORDERID));
        super.onCopyDetails(et,objSourceKey);
    }
}